#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include "OpDoc.h"
#include "CmdParam.h"
#include "MyException.h"
#include "textContent.h"
#include "TextDoc.h"
#include "Codedoc.h"
#include "WordPack.h"
using std::string;
using std::cout;

int main(int argc, char ** argv)
{

	//textContent TC; 
	//textContent TC1;
	//textContent TC2;
	//textContent TC3;	
	//
	/*TC1.setBin(true);*/
	
	//TextDoc TD("orginal.txt",0,&TC1);
	//Codedoc CD("code1.bin",1,&TC1);
	//Codedoc CD1("code1.bin",0,&TC);
	//TextDoc TD1("text1.txt",1,&TC);
	//
	/*TextDoc TD2("text1.txt",0,&TC2);
	Codedoc CD2("code2.dat",1,&TC2);
	Codedoc CD3("code2.dat",0,&TC3);
	TextDoc TD3("text2.txt",1,&TC3);*/

	//std::fstream myFile;
	//std::fstream *fprt;
	//fprt = &myFile;
	//WordPack wp("data1.bin",3,4);
	//wp.writeInt(0);
	//wp.writeInt(1);
	//wp.writeInt(3);
	//wp.writeWord("test0");
	//wp.writeWord("1");
	//wp.writeWord("tt2");
	//wp.writeWord("teeeeeeeeeeest3");
	//wp.close();

	//WordPack wp1("data1.bin");
	//cout << wp1.getInt() << endl;
	//cout << wp1.getInt() << endl;
	//cout << wp1.getInt() << endl;
	//cout << wp1.getWord() << endl;
	//cout << wp1.getWord() << endl;
	//cout << wp1.getWord() << endl;
	//cout << wp1.getWord() << endl;
	//wp1.close();


	//int i = 258,e=222,highByte,lowByte,res;
	//char unsigned cc = char(e),hchar,lchar,hchar2,lchar2;
	//if(i<128)
	//{
	//	highByte = i;
	//	lowByte = 0;	
	//	myFile << char(highByte);
	//	myFile.close();
	//		
	//}
	//else
	//{
	//	highByte = (i/256);
	//	lowByte = i-(256*highByte);
	//	highByte += 127;
	//	myFile << char(highByte) << char(lowByte);
	//	myFile.close();
	//}
	//cout << highByte << " " << lowByte << endl;

	//hchar = char(highByte);
	//lchar = char(lowByte);

	//cout << hchar << " " << lchar << endl;



	//highByte = 0;
	//lowByte = 0;
	//hchar = char(0);
	//lchar = char(0);
	//hchar2 = 0;
	//lchar2 = 0;

	//myFile.open("data.bin" , ios::in | ios::binary);
	//myFile >> hchar2;
	//
	//if(hchar2<128)
	//{
	//	res = hchar2;
	//}
	//else
	//{
	//	myFile >> lchar2;
	//	cout << hchar2 << " " << lchar2 << endl;
	//	hchar2 = hchar2-127;
	//	res = (hchar2 * 256) + lchar2;
	//}

	//
	//cout << res << endl;


	//string test;
	//std::stringstream ostr;	
	//ostr << e;
	//test = ostr.str();
	//cout << ostr.str() << " " << char(e);
	/*
	std::fstream myFile("data.bin", ios::out | ios::binary);

	int i = 12,e=222,h_nib,l_nib,res;
	char unsigned cc = char(e),hchar,lchar,hchar2,lchar2;
	if(i<128)
	{
		h_nib = i;
		l_nib = 0;
	}
	else
	{
	h_nib = (i/256);
	l_nib = i-(256*h_nib);
	h_nib += 127;
	}
	cout << h_nib << " " << l_nib << endl;

	hchar = char(h_nib);
	lchar = char(l_nib);

	cout << hchar << " " << lchar << endl;

	myFile << hchar << lchar;
	myFile.close();

	h_nib = 0;
	l_nib = 0;
	hchar = char(0);
	lchar = char(0);
	hchar2 = 0;
	lchar2 = 0;

	myFile.open("data.bin" , ios::in | ios::binary);
	myFile >> hchar2;
	
	if(hchar2>126)
	{
		hchar2 = hchar2-127;
		myFile >> lchar2;
		res = (hchar2 * 256) + lchar2;
	}
	else
	{
		res = hchar2;
	}

	cout << hchar2 << " " << lchar2 << endl;
	cout << res << endl;
	*/


	CmdParam cmdP(argc,argv);
	OpDoc od(cmdP);
	od.run();
	cout << endl << "done" << endl;
	char c;
	std::cin >> c;
}
